package net.seehealth.healthpad.application.service;

import java.io.IOException;

import net.seehealth.healthpad.Constants;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;

public class UpLoadXMLFileSerivice {
	public boolean connectWebservice(String uploadBuffer){
		boolean bool = false;
		SoapObject request = new SoapObject(Constants.Common.UPLOADXMLTARGETNAMESPACE,Constants.Common.UPLOADXMLMETHOD);
		request.addProperty("XML", uploadBuffer);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
		envelope.setOutputSoapObject(request);
		HttpTransportSE jtse = new HttpTransportSE(Constants.Common.UPLOADXMLWSDL);
		try {
			jtse.call(null, envelope);
			SoapObject so =(SoapObject)envelope.bodyIn;
			bool = Boolean.valueOf(so.getProperty("return").toString());
			return bool;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (XmlPullParserException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}
